<div id="form"></div>
<script>
var inputs={{JSON:modeldef.show_inputs}};
var frm=$("#form").ajajform({
	header: "{{modeldef.label_title}}",
	submit: {
		url: '<{>action<}>',
		value: "{{modeldef.label_save_and_exit}}",
		ajaj: true,
		click: function() { frm.ajajform("setSubmitParam","mode","save"); return 1; },
		params: {{JSON:modeldef.params}},
	},
	footerButtons: [
		<{>if {{modeldef.name}}.id<}>	
		{value: "{{modeldef.label_delete}}", click: function() {if (confirm("Are you sure to delete?")) std_response($.ajax({type:"post",url: "<{>action<}>",data:{mode: "delete",ajaj:1,id:<{>{{modeldef.name}}.id<}>},async:false}).responseText)} },
		<{>/if<}>
		{value: "{{modeldef.label_save_and_continue}}", click: function() { frm.ajajform("setSubmitParam","mode","save_only");frm.ajajform("submitClicked"); } }
		{{modeldef.edit_footer_buttons_html_add}}
	]
});
for (var i=0;i<inputs.length;i++) {
	frm.ajajform("insertWidget",null,null,inputs[i]);
}
</script>
{{modeldef.footer_html}}
